
cd ""
*use "data_main.dta", clear
import delimited "data_main.txt", encoding(ISO-8859-9) clear 
format date %td

tsset city date
gen ld=log(debit)
encode state, gen(ss)
encode fed, gen(ff)

tsset city a
gen dld=ld-l.ld
bys city: egen me=mean(debit)
gen mis=1 if debit==.
by city: egen tot_mis=max(mis)
 bys city: egen ab=min(dld)
  bys city: egen aa=max(dld)

  
  gen debit2=debit+l.debit
gen debit_cum=debit if a==1
replace debit_cum=l.debit_cum+debit if a>1

keep if a==3 | a==5 | a==7 | a==9 | a==11 | a==13 | a==15 | a==17 | a==19 | a==21 | a==23 | a==25 | a==27 | a==29 | a==31 | a==33 | a==35 | a==37 | a==39 | a==41 | a==43 | a==45 | a==47 | a==49 | a==51 

replace a=a/2-0.5

tsset city a
gen ld2=log(debit2)
gen ld_cum=log(debit_cum)
gen ld_cum_2=log(debit_cum/a)
char a[omit] 8


gen d_after=1 if a==9 | a==10
replace d_after=0 if a==8 | a==7
gen d_radio=d_after*radio


*Table 1

xi: reghdfe ld2 i.d_after*radio if tot_mis!=1 , absorb(city   ) cluster(city )
xi: reghdfe ld2 i.d_after*radio if tot_mis!=1 , absorb(city  ss#a  ) cluster(city )
xi: reghdfe ld2 i.d_after*radio if tot_mis!=1 , absorb(city ss#a ff#a  ) cluster(city )
xi: reghdfe ld2 i.d_after*radio if ab>-1.0 & aa<1.0 & me<64725 &  tot_mis!=1 & me>552 , absorb(city ss#a ff#a  ) cluster(city )
xi: reghdfe ld2 i.d_after*radio  c.a#c.black  c.a#c.urban c.a#c.d_old if ab>-1.0 & aa<1.0 & me<64725 &  tot_mis!=1 & me>552 , absorb(city ss#a ff#a  ) cluster(city )

*Table 2

gen radio_circulation=radio*circulation
xi: reghdfe ld2 i.d_after*radio i.d_after*circulation if tot_mis!=1 , absorb(city   ) cluster(city )
xi: reghdfe ld2 i.d_after*radio i.d_after*circulation if tot_mis!=1 , absorb(city  ss#a  ) cluster(city )
xi: reghdfe ld2 i.d_after*radio i.d_after*circulation if tot_mis!=1 , absorb(city ss#a ff#a  ) cluster(city )
xi: reghdfe ld2 i.d_after*radio i.d_after*circulation if ab>-1.0 & aa<1.0 & me<64725 &  tot_mis!=1 & me>552 , absorb(city ss#a ff#a  ) cluster(city )
xi: reghdfe ld2 i.d_after*radio  i.d_after*circulation c.a#c.black  c.a#c.urban c.a#c.d_old if ab>-1.0 & aa<1.0 & me<64725 &  tot_mis!=1 & me>552 , absorb(city ss#a ff#a  ) cluster(city )
xi: reghdfe ld2 i.d_after*radio  i.d_after*circulation  i.d_after*radio_circulation c.a#c.black  c.a#c.urban c.a#c.d_old if ab>-1.0 & aa<1.0 & me<64725 &  tot_mis!=1 & me>552 , absorb(city ss#a ff#a  ) cluster(city )

*Table 3

replace pcrel35=pcrel35/1000

reg  radio own if a==8 & tot_mis!=1, r
reg   radio unem if a==8 & tot_mis!=1, r
reg  radio d_old  if a==8 & tot_mis!=1, r
reg  radio black  if a==8 & tot_mis!=1, r
reg  radio pcrel35   if a==8 & tot_mis!=1, r
*Table 4
xi: reghdfe ld2 i.d_after*own  if ab>-1.0 & aa<1.0 & me<64725 &  tot_mis!=1 & me>552 , absorb(city ss#a ff#a  ) cluster(city )
xi: reghdfe ld2 i.d_after*radio  i.d_after*own  if ab>-1.0 & aa<1.0 & me<64725 &  tot_mis!=1 & me>552 , absorb(city ss#a ff#a  ) cluster(city )
xi: reghdfe ld2 i.d_after*unem if ab>-1.0 & aa<1.0 & me<64725 &  tot_mis!=1 & me>552 , absorb(city ss#a ff#a  ) cluster(city )
xi: reghdfe ld2 i.d_after*radio  i.d_after*unem if ab>-1.0 & aa<1.0 & me<64725 &  tot_mis!=1 & me>552 , absorb(city ss#a ff#a  ) cluster(city )
xi: reghdfe ld2 i.d_after*d_old if ab>-1.0 & aa<1.0 & me<64725 &  tot_mis!=1 & me>552 , absorb(city ss#a ff#a  ) cluster(city )
xi: reghdfe ld2 i.d_after*radio  i.d_after*d_old if ab>-1.0 & aa<1.0 & me<64725 &  tot_mis!=1 & me>552 , absorb(city ss#a ff#a  ) cluster(city )
xi: reghdfe ld2 i.d_after*black if ab>-1.0 & aa<1.0 & me<64725 &  tot_mis!=1 & me>552 , absorb(city ss#a ff#a  ) cluster(city )
xi: reghdfe ld2 i.d_after*radio  i.d_after*black if ab>-1.0 & aa<1.0 & me<64725 &  tot_mis!=1 & me>552 , absorb(city ss#a ff#a  ) cluster(city )
xi: reghdfe ld2 i.d_after*pcrel35 if ab>-1.0 & aa<1.0 & me<64725 &  tot_mis!=1 & me>552 , absorb(city ss#a ff#a  ) cluster(city )
xi: reghdfe ld2 i.d_after*radio  i.d_after*pcrel35 if ab>-1.0 & aa<1.0 & me<64725 &  tot_mis!=1 & me>552 , absorb(city ss#a ff#a  ) cluster(city )






